#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <sstream>	//stringstream
#include <algorithm>
#include <fstream>
#include <cmath>
#include <float.h>

using namespace std;

//			--------------
//			--- struct ---
//			--------------

struct Node
{
	string name;
	float x;
	float y;
};

struct Edge
{
	string source;
	string target;
	float weight;
};

struct Task
{
	Node source;
	Node target;
	string order;
};

struct Command
{
	vector<string> help;
	vector<string> source;
	vector<string> target;
	vector<string> route;
	vector<string> exit;

	vector<string> isConnected;
	vector<string> routeWeight;
};

//			-------------
//			--- class ---
//			-------------

class Run {
private:
	bool running;
public:
	void Init(class Graph&, class Read&, class Write&, class Console&, string);
	void Core();

	void ShutDown();
	bool IsRunning();

	void SetEdges(class Graph&, vector<string>* const);
	void SetNodes(class Graph&, vector<string>* const);
	
	string Converter(int);
	float Converter(string);
};

class Graph: public Run
{
private:
	vector<Node> nodes;
	vector<Edge> edges;
	map<Node*, vector<Edge> > neighbors;
public:
	void AddNode(Node* node);
	void AddNode(Node& node);
	void RemoveNode(Node* node);
	void RemoveNode(Node& node);
	void RemoveNode(int);

	void AddEdge(Edge* edge);
	void AddEdge(Edge& edge);
	void RemoveEdge(Edge* edge);
	void RemoveEdge(Edge& edge);
	void RemoveEdge(int);

	Node GetNode(int);
	Node GetNode(string);
	int NodeValue(Node&);
	bool ContainsNode(Node&);
	bool ContainsNode(Node*);

	Edge GetEdge(int);
	int EdgeValue(Edge&);
	bool ContainsEdge(Edge&);
	bool ContainsEdge(Edge*);

	int NodeSize();
	string StrNodeSize();
	int EdgeSize();
	string StrEdgeSize();

	void ClearNode();
	void ClearEdge();
	void Clear();

	void Init();
	string Converter(int);
};

class Read
{
private:
	string fileName;
	int lines;
public:
	void SetFileName(string);
	void SetLines();

	string GetFileName();
	string ReadLine(int);
	vector<string> ReadLines();
	int GetLines();

};

class Write
{
private:
	string fileName;
public:
	void SetFileName(string);

	string GetFileName();
	void WriteLine(string);
	void WriteLine(vector<string>, string, int);
	void WriteLines(vector<string>);

};

class Console
{
private:
	string commandFile;
	string delimiter;
	Command commands;
	string source;
	string target;
public:
	vector<string> Split(vector<string>);
	vector<string> Split(string);
	vector<string> Split(string, string);

	Command Sort(vector<string>* const);
	void Init();

	string GetComFile();
	string GetDelimiter();
	void SetComFile(string);
	void SetDelimiter(string);

	Command GetCommands();
	void SetCommands(Command);

	void Help();
	string GetInput();
	Task GetTask(class Graph&);
	vector<char> LowerCase(char[]);
	vector<char> LowerCase(vector<char>);
	string LowerCase(string);
	bool Includes(vector<string>, vector<string>);

	string GetSource();
	string GetTarget();
	void SetSource(string);
	void SetTarget(string);
};

